﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using EShop.BLL;
using EShop.Model;
using EShop.Common;

namespace EShop.Client
{
    public partial class frmMerchandiseUnitManger : frmBase
    {
        public frmMerchandiseUnitManger()
        {
            InitializeComponent();
        }
        MerchandiseUnitBLL oMerchandiseUnitBLL = new MerchandiseUnitBLL();
        private void frmMerchandiseUnitManger_Load(object sender, EventArgs e)
        {
            GetAllUnit();
        }

        private void GetAllUnit()
        {
            this.lstUnit.Items.Clear();
            foreach (MerchandiseUnitInfo info in oMerchandiseUnitBLL.GetAllMerchandiseUnitList())
            {
                lstUnit.Items.Add(info.UnitName);
            }
        }

        private void btnSumbit_Click(object sender, EventArgs e)
        {
            string strUnit = SystemLibrary.SQLQuoteName(txtUnit.Text.Trim());
            if (string.IsNullOrEmpty(strUnit)) return;
            if (oMerchandiseUnitBLL.MerchandiseUnitAppend(strUnit))
            {
                MessageBox.Show("添加成功");
                GetAllUnit();
                this.txtUnit.Clear();
            }
            else
            {
                MessageBox.Show("单位: " + strUnit + " 已经存在");
                this.txtUnit.Clear();
            }
        }
    }
}
